Scientific Computing with Scala by Vytautas Jancauskas

Scientific Computing with Scala by Vytautas Jancauskas

Author:Vytautas Jancauskas [Jancauskas, Vytautas]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-04-27T04:00:00+00:00


You can also use sortedColsBy() to sort columns the same way as we did for rows. All the arithmetic operations that worked on Series will similarly work on frames. See the following examples. As you can see, only the columns and rows that are represented in both of the frames are present in the results. The elements which lack a corresponding element in the other matrix will be represented by NA:

scala> val f1 = Frame('x' -> Series('a' -> 0.1, 'b' -> 0.2, 'c' -> 0.3), 'y' -> Series('a' -> 0.4, 'b' -> 0.5, 'c' -> 0.6)) f1: org.saddle.Frame[Char,Char,Double] = [3 x 2] x y ------ ------ a -> 0.1000 0.4000 b -> 0.2000 0.5000 c -> 0.3000 0.6000 scala> val f2 = Frame('y' -> Series('b' -> 0.7, 'c' -> 0.8, 'd' -> 0.9), 'z' -> Series('b' -> 1.0, 'c' -> 1.1, 'd' -> 1.2)) f2: org.saddle.Frame[Char,Char,Double] = [3 x 2] y z ------ ------ b -> 0.7000 1.0000 c -> 0.8000 1.1000 d -> 0.9000 1.2000 scala> f1 * f2 res21: org.saddle.Frame[Char,Char,Double] = [4 x 3] x y z -- ------ -- a -> NA NA NA b -> NA 0.3500 NA c -> NA 0.4800 NA d -> NA NA NA scala> f1 - f2 res22: org.saddle.Frame[Char,Char,Double] = [4 x 3] x y z -- ------- -- a -> NA NA NA b -> NA -0.2000 NA c -> NA -0.2000 NA d -> NA NA NA



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.